var template = '<div class="modal">' +
							'<div class="modal-dialog">' +
								'<div class="modal-content">' +
									'<div class="modal-header">' +
										'<button type="button" class="close" data-dismiss="modal">' +
											'<span>&times;</span><span class="sr-only">Close</span>' +
										'</button>' +
										'<div class="tit">' +
											'<h4 class="modal-title">aaa</h4>' +
										'</div>' +
									'</div>' +
									'<div class="modal-body">' +
										'<h4 class="tel">' +
											'bbb' +
										'</h4>' +
									'</div>' +
									'<div class="modal-footer">' +
										'<button type="button" class="btn btn-default" data-dismiss="modal">知道了</button>'+
									'</div>' +
								'</div>' +
							'</div>' +
						'</div>';
						
var dialog = $(template);

jQuery.extend({
	alert : function(title,content){
		var clear = '<button type="button" class="btn btn-default" data-dismiss="modal">知道了</button>';
		dialog.find('.modal-title').html(title);
		dialog.find('.tel').html(content);
		dialog.find('.modal-footer').html(clear);
		dialog.modal('show');
	},
	confirm : function(title,content){
		dialog.find('.modal-title').html(title);
		dialog.find('.tel').html(content);
		
		var butsHtml = '<button id="verify" class="btn btn-success" style="float:left;">确认</button>'+
						'<button type="button" class="btn btn-warning" data-dismiss="modal">取消</button>';
						
		dialog.find('.modal-footer').html(butsHtml);
		dialog.modal('show');
	},
	upload : function(title){
	var mocontent = '<form>'+
						'<div class="form-group">'+
							'<input name="img" class="fileinput" type="file" />'+
						'</div>'+
					'</form>';
	var foo = '<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>';
	dialog.find('.modal-title').html(title);
	dialog.find('.modal-body').html(mocontent);
	dialog.find('.modal-footer').html(foo);
	dialog.modal('show');
	},
	login : function(title){
		var gincontent = '<div class="info">'+
							'</div>'+
							'<br /><br>'+
	                   	 	'<form id="login1" class="form-horizontal">'+
	                        	'<div class="form-group">'+
	                            	'<label class="control-label col-sm-4 col-md-4 col-lg-4 hidden-xs control-lable" for="lgninp">登录名：</label>'+
	                            	'<div class="col-sm-7 col-md-8 col-lg-6">'+
	                            		'<div class="input-group">'+
	                            		'<div class="input-group-addon">'+
	                            			'<span class="glyphicon glyphicon-user"></span>'+
	                            		'</div>'+
	                            		'<input id="lgninp" required="required" name="login" class="form-control" placeholder="登录名">'+
	                            		'</div>'+
	                            	'</div>'+
	                        	'</div>'+
								'<br><br>'+
	                    		'<div class="form-group">'+
	                            	'<label class="control-label col-sm-5 col-md-4 col-lg-4 hidden-xs" for="pwdinp">密　码：</label>'+
	                            		'<div class="col-sm-7 col-md-8 col-lg-6">'+
	                            			'<div class="input-group">'+
	                            				'<div class="input-group-addon">'+
	                            				'<span class="glyphicon glyphicon-lock"></span>'+
	                            				'</div>'+
	                            				'<input id="pwdinp" required="required" name="password" type="password" class="form-control" placeholder="密码">'+
	                            			'</div>'+
	                            		'</div>'+
	                        	'</div>'+
	                    	'</form>';
		var butsHtml = '<button id="verify" class="btn btn-default">确认</button>'+
						'<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>';
						
		dialog.find('.modal-footer').html(butsHtml);
		dialog.find('.modal-title').html(title);
		dialog.find('.modal-body').html(gincontent);
		dialog.modal('show');
	},
	block: function (par) {
	    $(par).css({ 'display': 'block' });
	},
	inlineblock: function (par) {
	    $(par).css({ 'display': 'inline-block' });
	},
	none: function (par) {
	    $(par).css({ 'display': 'none' });
	},
	viewimg: function viewimg(input, img) {
	    $(input).change(function () {
	        var fr = new FileReader();

	        $(fr).load(function () {
	            $(img).attr('src', this.result);
	        });

	        fr.readAsDataURL(this.files[0]);
	    });
	}
});
